package com.xjoyt.pay.share.controllers;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.xjoyt.pay.controllers.AbstractController;
import com.xjoyt.pay.dto.ExecuteResult;
import com.xjoyt.pay.dto.PageParam;
import com.xjoyt.pay.dto.PageResult;
import com.xjoyt.pay.share.interfaces.SmsContract;
import com.xjoyt.pay.share.params.PhoneCodeParam;
import com.xjoyt.pay.share.params.SmsPageParam;
import com.xjoyt.pay.share.po.Sms;
import com.xjoyt.pay.share.services.SmsService;

@RestController
@RequestMapping("sms")
public class SmsController extends AbstractController implements SmsContract {

	@Autowired
	private SmsService service;

	@Override
	public ExecuteResult<String> getCode(@RequestBody PhoneCodeParam param) throws Exception {
		return service.sendCode(param);
	}

	@Override
	public PageResult<Sms> loadPage(@RequestBody PageParam<SmsPageParam> param) {
		return service.loadPage(param);
	}

	@Override
	public ExecuteResult<String> validateCode(@RequestBody PhoneCodeParam param) throws Exception {
		return service.validate(param);
	}

	@Override
	public ExecuteResult<?> removeCode(PhoneCodeParam param) throws Exception {
		return service.remove(param);
	}
}
